﻿package  effect.image.tool
{
	//删除容器里面所有子对象工具,更改容器的注册点工具
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.geom.Point;
	import flash.display.DisplayObject;
	
	public  final class Contain
	{


		//删除容器里所有的内容
		public static function clearAll(contain:DisplayObjectContainer):void
		{
			while (contain.numChildren>0)
			{
				contain.removeChildAt(0);
			}
		}

		//删除数组里所有的数据
		public static function clearArray(array:Array):void
		{
			while (array.length)
			{
				array.pop();
			}
		}
		
		// 更改容器里注册点位置
		public static function RegPoint(obj:MovieClip , point:Point):void
		{
			var tmp_point:Point=obj.parent.globalToLocal(obj.localToGlobal(point));
			var len:int=obj.numChildren;
			while (len--)
			{
				var tmp_obj:DisplayObject=obj.getChildAt(len);
				tmp_obj.x-=point.x;
				tmp_obj.y-=point.y;
			}
			obj.x=tmp_point.x;
			obj.y=tmp_point.y;
			
		}
		
	}
}